package com.qf.bbapi.controller;

import com.qf.bbapi.entity.TCoincertificate;
import com.qf.bbapi.entity.TExchangeIntegral;
import com.qf.bbapi.service.impl.TCoincertificateImpl;
import com.qf.bbapi.service.intf.TCoincertificateService;
import com.qf.bbapi.service.intf.TExchangeIntegralService;
import com.qf.bbapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * .::::.
 * .::::::::.
 * :::::::::::
 * ..:::::::::::'
 * '::::::::::::'
 * .::::::::::
 * '::::::::::::::..
 * ..::::::::::::.
 * ``::::::::::::::::
 * ::::``:::::::::'        .:::.
 * ::::'   ':::::'       .::::::::.
 * .::::'      ::::     .:::::::'::::.
 * .:::'       :::::  .:::::::::' ':::::.
 * .::'        :::::.:::::::::'      ':::::.
 * .::'         ::::::::::::::'         ``::::.
 * ...:::           ::::::::::::'              ``::.
 * ````':.          ':::::::::'                  ::::..
 * '.:::::'                    ':'````..
 *
 * @author 贾
 * @version 1.0
 * @description: TODO
 * @date 2022/7/3 12:18
 */
@RestController
@Api(tags = "积分兑换券")
@CrossOrigin
@RequestMapping("/api/techange/")
public class TechangeIntegralController {
    @Resource
    TExchangeIntegralService service;
    @Resource
    TCoincertificateService coincertificateService;

    @ApiOperation("兑换优惠券")
    @GetMapping("exchange.do")
    public R exchange(TExchangeIntegral integral, HttpServletRequest request){
        System.out.println(integral);
        return service.exchange(integral,request.getIntHeader("token"));
    }

    @ApiOperation("查询优惠券")
    @GetMapping("all.do")
    public R all(HttpServletRequest request){
        return coincertificateService.all(request.getIntHeader("token"));
    }
}
